<?php
session_start();
require_once('../config.php');
?>
<div class="close_listicon" onclick="closethis();"><img src="./style/default/close.png" border="0" /></div>
<?php
if(isset($_SESSION[sess_login]))
{
	$array_list='';
	$flag = false;
	include("../connect.php");
	$sql = "SELECT `id`, `groupname` FROM `user_groupview` WHERE `owner` = '".$_SESSION[sess_login]['id']."' AND `groupname` NOT IN ('".name_db_friendlist."')";
	$result = @mysql_query($sql, $conn);

	if (@mysql_num_rows($result)!=0){
		while ($row = @mysql_fetch_row($result)){ 
			$array_list[] = $row;
		}
		$flag = true;
	}
	@mysql_free_result($result);
	mysql_close($conn);

	if($flag){
		sort($array_list);
		echo '<div class="form_save_add_member uix-button" onclick="group_to_album();"> &nbsp; DONE &nbsp; </div>';
		echo '<ul class="list_group_select">';
		foreach($array_list as $each_group => $vallist){
			echo '<li><input type="checkbox" value="'.$vallist[0].'" alt="'.$vallist[1].'" name="select_group"> <a>'.$vallist[1].'</a></li>';
		}
		echo '</ul>';
		
		echo '<script>
			$("#loadlistgroup ul.list_group_select li a").click(
				function() { 
					if($(this).parent().find("input:checkbox").is(":checked")){
						$(this).parent().find("input:checkbox").removeAttr("checked").parent().removeClass("selected");
					} else {
						$(this).parent().find("input:checkbox").attr("checked","checked").parent().addClass("selected");
					}
				}
			);
			$("#loadlistgroup ul.list_group_select li input:checkbox").click(
				function() { 
					if(!$(this).is(":checked")){
						$(this).removeAttr("checked").parent().removeClass("selected");
					} else {
						$(this).attr("checked","checked").parent().addClass("selected");
					}
				}
			);
			</script>';

	}
	else{
		echo 'No friend group... You have to add them in your group';
	}
}
else{
	echo "<br />Wrong variables <br />";
}

?>
